package pl.edu.agh.model.core;

import javax.persistence.Column;
import javax.persistence.Entity;
import java.util.Date;

@Entity
public class Price extends DomainObject {
    @Column
    private String description;

    @Column
    private Date date;

    @Column
    private Double open;

    @Column
    private Double high;

    @Column
    private Double low;

    @Column
    private Double close;

    @Column
    private Double income;

    @Column
    private Long volume;

    public Price() {
    }

    public Price(String description, Date date, Double open, Double high, Double low, Double close, Double income, Long volume) {
        check(low, open);
        check(low, high);
        check(low, close);
        check(open, high);
        check(close, high);

        this.description = description;
        this.date = date;
        this.open = open;
        this.high = high;
        this.low = low;
        this.close = close;
        this.income = income;
        this.volume = volume;
    }

    private void check(Double d1, Double d2){
        assert d1 <= d2 : d1 + " not <= " + d2;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Double getOpen() {
        return open;
    }

    public void setOpen(Double open) {
        this.open = open;
    }

    public Double getHigh() {
        return high;
    }

    public void setHigh(Double high) {
        this.high = high;
    }

    public Double getLow() {
        return low;
    }

    public void setLow(Double low) {
        this.low = low;
    }

    public Double getClose() {
        return close;
    }

    public void setClose(Double close) {
        this.close = close;
    }

    public Double getIncome() {
        return income;
    }

    public void setIncome(Double income) {
        this.income = income;
    }

    public Long getVolume() {
        return volume;
    }

    public void setVolume(Long volume) {
        this.volume = volume;
    }
}
